package com.lzw.springbootredis.listener;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

/**
 * @program: springboot-redis
 * @description: Redis消息监听器
 * @author: lizhiwei
 * @create: 2019-06-13 10:52
 **/
@Component
public class RedisMessgeListener implements MessageListener {

    @Override
    public void onMessage(Message message, byte[] pattern) {
        //消息体
        String body = new String(message.getBody());
        //渠道名称
        String topic = new String(pattern);
        System.out.println(body);
        System.out.println(topic);
    }
}
